/*
 * Copyright (C) 2017 The Android Open Source Project
 *
 * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file
 * except in compliance with the License. You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software distributed under the
 * License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
 * KIND, either express or implied. See the License for the specific language governing
 * permissions and limitations under the License.
 */

package com.android.systemui.plugins.qs;

import android.content.Context;
import android.content.Intent;
import android.view.View;
import android.view.ViewGroup;

import com.android.systemui.plugins.annotations.ProvidesInterface;

@ProvidesInterface(version = DetailAdapter.VERSION)
public interface DetailAdapter {
    int VERSION = 1;

    CharSequence getTitle(); // 标题
    Boolean getToggleState(); // 当前开关的状态

    // 是否启用开关
    default boolean getToggleEnabled() {
        return true;
    }

    /**
     * 创建具体的view

     * @param convertView 不为null则为缓存的view，可复用
     */
    View createDetailView(Context context, View convertView, ViewGroup parent);

    // 当点击“更多设置”时的Intent
    Intent getSettingsIntent();

    // 设置开关
    void setToggleState(boolean state);

    // 获取类别，可用来缓存view
    int getMetricsCategory();

    /**
     * Indicates whether the detail view wants to have its header (back button, title and
     * toggle) shown.
     *
     * 指示 DetailView 是否要显示其标题（后退按钮，标题和开关）。
     */
    default boolean hasHeader() {
        return true;
    }
}
